import scala.io.Source
object 课后作业1 {
  val phone_number = "\\d{11}".r //用phone_number存放11位手机号
  val data = Source.fromFile("课后作业1.txt").getLines().toList  //读取课后作业1.txt
  
  //定义check方法进行检查
  def check(x: String) = {
    phone_number.findFirstMatchIn(x) match {
      case None => println(x)  //打印错误手机号
      case _ =>  //正确的话不进行任何操作
    }
  }
  
  //定义screen方法进行筛选
  def screen(x: Int): List[Long] = {
    val moubile_number = "^" + x.toString + "\\d{8}"
    var l1: List[Long] = Nil
    for (j <- data) {
      moubile_number.r.findFirstMatchIn(j) match {
        case Some(s) => l1 = s.toString().toLong :: l1
        case _ =>
      }
    }
    return l1
  } 
  //main方法
  def main(args: Array[String]) {
    data.foreach(check)
    print(screen(150))   
   }
}